package com.adv.ems.controller.admin;

import com.adv.ems.constants.SystemConst;
import com.adv.ems.model.dto.APIRequest;
import com.adv.ems.model.dto.APIResponse;
import com.adv.ems.model.param.BaseQueryParam;
import com.adv.ems.model.vo.BaseEnergyFeeVO;
import com.adv.ems.service.BaseDataService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/ems/client/base/energy/fee")
public class EnergyFeeInfoController {
    @Resource
    BaseDataService baseDataService;

    @PostMapping("/list")
    public APIResponse<BaseEnergyFeeVO> list(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                            @RequestBody APIRequest<BaseQueryParam> request) {
        return APIResponse.<BaseEnergyFeeVO>build().content(baseDataService.energyFeeList(request.getContent(), acceptLanguage));
    }

    @PostMapping("/update")
    public APIResponse<Boolean> update(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                            @RequestBody APIRequest<BaseEnergyFeeVO.Info> request) {
        return APIResponse.<Boolean>build().content(baseDataService.energyFeeUpdate(request.getContent(), acceptLanguage));
    }

    @PostMapping("/delete")
    public APIResponse<Boolean> delete(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                       @RequestBody APIRequest<Long> request) {
        return APIResponse.<Boolean>build().content(baseDataService.energyFeeDelete(request.getContent(), acceptLanguage));
    }
}
